package ins;

import java.util.List;

import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.junit.Test;
import org.lanqiao.tjut.db.DBDriverFactory;
import org.lanqiao.tjut.entity.EMPSubEntity;
import org.lanqiao.tjut.entity.ESCOREEntity;
import org.lanqiao.tjut.entity.SScoreEntity;

public class Player {
	@Test
	public void doInsert() {
		String strSQL = "insert into s_score(p_id,p_name,p_score) values(?,?,?)";
		DBDriverFactory.getDBDriverInstance().batch(strSQL, new Object[][] {{ 1, "乔纳森·乔斯达",0 },{ 2, "乔瑟夫·乔斯达",0 },{ 3, "空条承太郎",0},{ 4, "东方仗助",0},{ 5, "乔鲁诺·乔巴拿",0},{ 6, "空条徐伦",0 }});
		
	}
	@Test
	public void doRegister() {
		// TODO Auto-generated method stub
		String strSQL = "insert into s_score(p_id,p_name) values(?,?)";
		DBDriverFactory.getDBDriverInstance().batch(strSQL, new Object[][] {{ 1, "乔纳森·乔斯达" },{ 2, "乔瑟夫·乔斯达" },{ 3, "空条承太郎"},{ 4, "东方仗助"},{ 5, "乔鲁诺·乔巴拿"},{ 6, "空条徐伦" }});
	}
	@Test
	public void doResult1() {
		// TODO Auto-generated method stub
		String strSQL="select * from e_score";
		   List lst=(List)DBDriverFactory.getDBDriverInstance().query(strSQL,new BeanListHandler(ESCOREEntity.class));
	       printList(lst);
	}
	@Test
	public void doResult2() {
		// TODO Auto-generated method stub
		String strSQL="select * from s_score";
		   List lst=(List)DBDriverFactory.getDBDriverInstance().query(strSQL,new BeanListHandler(SScoreEntity.class));
	       printList(lst);
	}
	@Test
	public void doResult3() {
		// TODO Auto-generated method stub
		String strSQL="select * from s_score where p_score=(select max(p_score)from s_score)";
		   List lst=(List)DBDriverFactory.getDBDriverInstance().query(strSQL,new BeanListHandler(SScoreEntity.class));
	       printList(lst);
	}
	private void printList(List lst) {
		
		System.out.println("list集合存储的二维表格内容：");
		for(int i=0;i<lst.size();i++){
			System.out.println(lst.get(i).toString());
		}
	}	
}
